
package com.hlkj.pay.service.common.impl;
/*
 * Hlpay-Plus aggregate payment system.
 * Copyright (c) 2024-2025 Hlpay Team Copyright has the right of final interpretation.
 */

import java.io.File;

import org.springframework.stereotype.Service;

import com.hlkj.framework.common.pojo.CommonResult;
import com.hlkj.framework.extension.executor.ExtensionExecutor;
import com.hlkj.framework.extension.scenario.BizScenario;
import com.hlkj.pay.dto.order.SchemeOrderDto;
import com.hlkj.pay.infrastructure.model.common.CommonAppDO;
import com.hlkj.pay.infrastructure.model.order.PayOrderDO;
import com.hlkj.pay.service.common.IWechatAppService;

import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @author HlpayTeam
 * @date 2024/12/30 17:38
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class WechatAppServiceImpl implements IWechatAppService {

    private final ExtensionExecutor extensionExecutor;

    @Override
    public CommonResult<SchemeOrderDto> urlLink(CommonAppDO commonAppDO, PayOrderDO payOrderDO, String page) {
        return extensionExecutor.execute(WechatAppExtPt.class, BizScenario.valueOf(commonAppDO.getType().toString()), ex -> ex.urlLink(commonAppDO, payOrderDO,page));
    }

    @Override
    public CommonResult<WxMaJscode2SessionResult> wxAppUserInfo(CommonAppDO commonAppDO, String code) {
        return extensionExecutor.execute(WechatAppExtPt.class, BizScenario.valueOf(commonAppDO.getType().toString()), ex -> ex.wxAppUserInfo(commonAppDO, code));
    }

    @Override
    public CommonResult<File> getwxacodeunlimit(CommonAppDO commonAppDO, String page, String scene) {
        return extensionExecutor.execute(WechatAppExtPt.class, BizScenario.valueOf(commonAppDO.getType().toString()), ex -> ex.getwxacodeunlimit(commonAppDO, page,scene));
    }

}
